<template>
  <a-select
    :size="size"
    :value="value"
    :default-value="defaultValue"
    @change="handleChange"
  >
    <template v-for="(item, i) in options">
      <a-select-opt-group v-if="item.items && item.items.length > 0" :key="i">
        <span slot="label">{{ item.label }}</span>
        <a-select-option
          v-for="(col, j) in (item.items || [])"
          :key="j"
          :value="col.value"
        >
          {{ col.label }}
        </a-select-option>
      </a-select-opt-group>
    </template>
  </a-select>
</template>
<script>
// 下拉控件
export default {
  props: {
    value: {
      type: [String, Number],
      default() {
        return ''
      },
    },
    size: {
      type: String,
      default: () => '',
    },
    defaultValue: {
      type: [String, Number],
      default() {
        return ''
      },
    },
    options: {
      type: Array,
      default() {
        return []
      },
    },
  },
  methods: {
    handleChange(value) {
      this.$emit('change', value)
    },
  },
}
</script>
